<?php
/**
 * User:chendenan
 * Created On 2022/3/21 0021 17:20
 */
namespace app\api\controller\mall;
use app\api\controller\ApiBase;
use app\common\lib\Show as ShowLib;
use app\common\business\Goods as GoodsBus;
class Lists extends ApiBase{
    public function index(){
        $pageSize = input("param.page_size",10,"intval");
        $categoryId = input("param.category_id",0,"intval");
        $keyword = input("param.keyword","","trim");
        if(!$categoryId){
            return ShowLib::success();
        }
        $data = [
            "category_path_id" => $categoryId,
        ];
        if(!empty($keyword)){
            $data['title'] = $keyword;
        }
        $field = input("param.field","order","trim");
        $order = input("param.order","desc","intval");
        $order = [$field=>$order];
        $goods = (new GoodsBus())->getNormalLists($data,$pageSize,$order);
        return ShowLib::success($goods);
    }
}